package com.ttx.pattern.example.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 写一个较为通用的"切面"类
 * @author TimFruit
 * @date 19-5-26 上午10:57
 */
public class ProxyInvocationHandler implements InvocationHandler {

    private Object target;

    public ProxyInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("增加事务...");
        return method.invoke(target, args);
    }
}
